import tkinter
class Draw:
    def __init__(self,title="画图软件"):
        self.root = tkinter.Tk()
        self.root.title(title)

        self.init_menu()
        self.init_canvas()


    def init_menu(self):
        # 主菜单
        self.main_menu = tkinter.Menu(self.root)
        # 图形菜单
        self.shape_menu = tkinter.Menu(self.main_menu,tearoff=False)

        self.shape_menu.add_command(label="直线",command=lambda :print("点击了直线"))
        self.shape_menu.add_command(label="椭圆", command=lambda: print("点击了椭圆"))
        self.shape_menu.add_command(label="矩形", command=lambda: print("点击了矩形"))

        self.main_menu.add_cascade(menu=self.shape_menu,label="图形")

        #颜色菜单
        self.color_menu = tkinter.Menu(self.main_menu,tearoff=False)

        self.color_menu.add_command(label="红色",command=lambda :print("点击了红色"))
        self.color_menu.add_command(label="绿色", command=lambda: print("点击了绿色"))
        self.color_menu.add_command(label="自定义", command=lambda: print("自定义"))

        self.main_menu.add_cascade(menu=self.color_menu,label="颜色")

        # 其他菜单
        self.other_menu = tkinter.Menu(self.main_menu,tearoff=False)
        self.other_menu.add_command(label="撤销",command=lambda :print("点击了撤销"))
        self.other_menu.add_command(label="清屏",command=lambda :print("点击了清屏"))
        self.other_menu.add_command(label="退出",command=lambda :print("点击了退出"))

        self.main_menu.add_cascade(label="其他",menu=self.other_menu)

        self.root.config(menu=self.main_menu)


    def init_canvas(self):
        self.root.maxsize(width=800,height=630)
        self.canvas=tkinter.Canvas(self.root,width=800,height=600)
        self.canvas.pack()



    def run(self):
        self.root.mainloop()


draw=Draw()
draw.run()